<?php

/*
 * CopyRight  : (C)2012-2099 HaoTeam Inc.
 * Document   : UserValidate.php
 * Created on : 2021-1-29 13:53:25
 * Author     : Tiger <1192851302@qq.com>
 * Description: This is NOT a freeware, use is subject to license terms.
 *              这即使是一个免费软件,使用时也请遵守许可证条款,得到当时人书面许可.
 *              未经书面许可,不得翻版,翻版必究;版权归属 HaoTeam Inc;
 */

namespace app\api\validates;

use think\Validate;

/**
 * 用户验证器
 * Class UserValidate
 * Tiger <1192851302@qq.com> 2021-1-29 13:53:25
 */
class UserValidate extends Validate {

    protected $rule = [
        'id' => 'require|number',
        'user_group' => 'require|number',
        'nickname' => 'require|chsDash|max:32',
        'password' => 'require|min:6|max:12',
        'repassword' => 'require|min:6|max:12|confirm:password',
        'mobile' => 'require|mobile|unique:user',
        'fullname' => 'require|chsDash|max:32',
        'identity' => 'require|idCard',
        'identity_front_image' => 'require|url',
        'identity_back_image' => 'require|url'
    ];
    protected $message = [
        'id.require' => 'ID不能为空',
        'id.number' => 'ID格式不正确',
        'user_group.require' => '用户组不能为空',
        'user_group.number' => '用户组格式不正确',
        'nickname.require' => '用户名不能为空',
        'nickname.chsDash' => '用户名只能是汉字、字母、数字和下划线_及破折号-',
        'nickname.max' => '用户名最大32个字符',
        'password.require' => '密码不能为空',
        'password.min' => '密码最少要6个字符',
        'password.max' => '密码最大12字符',
        'repassword.require' => '重复密码不能为空',
        'repassword.min' => '重复密码最少要6个字符',
        'repassword.max' => '重复密码最大12字符',
        'repassword.confirm' => '两次密码不一致',
        'mobile.require' => '手机号码不能为空',
        'mobile.mobile' => '手机号码格式不正确',
        'mobile.unique' => '手机号码已存在',
        'fullname.require' => '姓名不能为空',
        'fullname.chsDash' => '姓名只能是汉字、字母、数字和下划线_及破折号-',
        'fullname.max' => '姓名最大32个字符',
        'identity.require' => '身份证不能为空',
        'identity.idCard' => '身份证格式不正确',
        'identity_front_image.require' => '身份证照片不能为空',
        'identity_front_image.url' => '身份证照片格式不正确',
        'identity_back_image.require' => '身份证照片不能为空',
        'identity_back_image.url' => '身份证照片格式不正确',
    ];
    protected $scene = [
        'register' => ['mobile', 'user_group', 'password', 'repassword'],
        'forgot' => ['password', 'repassword'],
        'verify' => ['fullname', 'identity', 'identity_front_image', 'identity_back_image']
    ];

}
